/*
 * Copyright 2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mx.ymate.security.base.model;

import net.ymate.platform.core.beans.annotation.PropertyState;
import net.ymate.platform.core.persistence.IShardingable;
import net.ymate.platform.core.persistence.annotation.*;
import net.ymate.platform.persistence.jdbc.IDatabase;
import net.ymate.platform.persistence.jdbc.IDatabaseConnectionHolder;
import net.ymate.platform.persistence.jdbc.query.AbstractFieldConditionBuilder;
import net.ymate.platform.persistence.jdbc.query.FieldCondition;
import net.ymate.platform.persistence.jdbc.query.Query;
import net.ymate.platform.persistence.jdbc.support.BaseEntity;

/**
 * SecurityOperationLog generated By EntityMojo on 2022/07/03 14:13:14
 *
 * @author YMP (https://www.ymate.net/)
 */
@Entity(SecurityOperationLog.TABLE_NAME)
@Comment("操作日志表")
public class SecurityOperationLog extends BaseEntity<SecurityOperationLog, String> {

    private static final long serialVersionUID = 1L;

    @Id
    @Property(name = FIELDS.ID, nullable = false, length = 32)
    @Comment("id")
    @PropertyState(propertyName = FIELDS.ID)
    private String id;

    
    @Property(name = FIELDS.RESOURCE_ID, nullable = false, length = 32)
    @Comment("资源id 默认和客户端一致")
    @PropertyState(propertyName = FIELDS.RESOURCE_ID)
    private String resourceId;

    
    @Property(name = FIELDS.CLIENT, nullable = false, length = 100)
    @Comment("客户端")
    @PropertyState(propertyName = FIELDS.CLIENT)
    private String client;

    
    @Property(name = FIELDS.TITLE, nullable = false, length = 100)
    @Comment("标题")
    @PropertyState(propertyName = FIELDS.TITLE)
    private String title;

    
    @Property(name = FIELDS.TYPE, nullable = false, length = 32)
    @Comment("类型具体看配置")
    @PropertyState(propertyName = FIELDS.TYPE)
    private String type;

    
    @Property(name = FIELDS.TYPE_NAME, nullable = false, length = 32)
    @Comment("类型名称")
    @PropertyState(propertyName = FIELDS.TYPE_NAME)
    private String typeName;

    
    @Property(name = FIELDS.USER_ID, nullable = false, length = 32)
    @Comment("操作人")
    @PropertyState(propertyName = FIELDS.USER_ID)
    private String userId;

    
    @Property(name = FIELDS.USER_NAME, nullable = false, length = 100)
    @Comment("操作人名称")
    @PropertyState(propertyName = FIELDS.USER_NAME)
    private String userName;

    
    @Property(name = FIELDS.CREATE_TIME, nullable = false, length = 19)
    @Default("0")
    @Comment("创建时间")
    @PropertyState(propertyName = FIELDS.CREATE_TIME)
    private Long createTime;

    
    @Property(name = FIELDS.REQUEST_URL, nullable = false, length = 255)
    @Comment("请求路径")
    @PropertyState(propertyName = FIELDS.REQUEST_URL)
    private String requestUrl;

    
    @Property(name = FIELDS.REQUEST_PARAM, length = 16383)
    @Comment("请求参数")
    @PropertyState(propertyName = FIELDS.REQUEST_PARAM)
    private String requestParam;

    
    @Property(name = FIELDS.RETURN_CODE, nullable = false, length = 100)
    @Comment("返回错误码")
    @PropertyState(propertyName = FIELDS.RETURN_CODE)
    private String returnCode;

    
    @Property(name = FIELDS.RETURN_MESSAGE, nullable = false, length = 16383)
    @Comment("返回错误信息")
    @PropertyState(propertyName = FIELDS.RETURN_MESSAGE)
    private String returnMessage;

    
    @Property(name = FIELDS.RETURN_RESULT, nullable = false, length = 16383)
    @Comment("返回结果")
    @PropertyState(propertyName = FIELDS.RETURN_RESULT)
    private String returnResult;

    
    @Property(name = FIELDS.CLASS_NAME, nullable = false, length = 255)
    @Comment("类名称")
    @PropertyState(propertyName = FIELDS.CLASS_NAME)
    private String className;

    
    @Property(name = FIELDS.METHOD_NAME, nullable = false, length = 255)
    @Comment("方法名")
    @PropertyState(propertyName = FIELDS.METHOD_NAME)
    private String methodName;

    
    @Property(name = FIELDS.IP, nullable = false, length = 32)
    @Comment("ip地址")
    @PropertyState(propertyName = FIELDS.IP)
    private String ip;

    
    @Property(name = FIELDS.LOCATION, nullable = false, length = 255)
    @Comment("位置")
    @PropertyState(propertyName = FIELDS.LOCATION)
    private String location;

    
    @Property(name = FIELDS.OS, nullable = false, length = 255)
    @Comment("操作系统")
    @PropertyState(propertyName = FIELDS.OS)
    private String os;

    
    @Property(name = FIELDS.BROWSER, nullable = false, length = 255)
    @Comment("浏览器")
    @PropertyState(propertyName = FIELDS.BROWSER)
    private String browser;


    public SecurityOperationLog() {
    }

    public SecurityOperationLog(IDatabase dbOwner) {
        super(dbOwner);
    }

    public SecurityOperationLog(String id, String resourceId, String client, String title, String type, String typeName, String userId, String userName, Long createTime, String requestUrl, String returnCode, String returnMessage, String returnResult, String className, String methodName, String ip, String location, String os, String browser) {
        this.id = id;
        this.resourceId = resourceId;
        this.client = client;
        this.title = title;
        this.type = type;
        this.typeName = typeName;
        this.userId = userId;
        this.userName = userName;
        this.createTime = createTime;
        this.requestUrl = requestUrl;
        this.returnCode = returnCode;
        this.returnMessage = returnMessage;
        this.returnResult = returnResult;
        this.className = className;
        this.methodName = methodName;
        this.ip = ip;
        this.location = location;
        this.os = os;
        this.browser = browser;
    }

        public SecurityOperationLog(IDatabase dbOwner, String id, String resourceId, String client, String title, String type, String typeName, String userId, String userName, Long createTime, String requestUrl, String returnCode, String returnMessage, String returnResult, String className, String methodName, String ip, String location, String os, String browser) {
            super(dbOwner);
            this.id = id;
            this.resourceId = resourceId;
            this.client = client;
            this.title = title;
            this.type = type;
            this.typeName = typeName;
            this.userId = userId;
            this.userName = userName;
            this.createTime = createTime;
            this.requestUrl = requestUrl;
            this.returnCode = returnCode;
            this.returnMessage = returnMessage;
            this.returnResult = returnResult;
            this.className = className;
            this.methodName = methodName;
            this.ip = ip;
            this.location = location;
            this.os = os;
            this.browser = browser;
        }

    public SecurityOperationLog(String id, String resourceId, String client, String title, String type, String typeName, String userId, String userName, Long createTime, String requestUrl, String requestParam, String returnCode, String returnMessage, String returnResult, String className, String methodName, String ip, String location, String os, String browser) {
        this.id = id;
        this.resourceId = resourceId;
        this.client = client;
        this.title = title;
        this.type = type;
        this.typeName = typeName;
        this.userId = userId;
        this.userName = userName;
        this.createTime = createTime;
        this.requestUrl = requestUrl;
        this.requestParam = requestParam;
        this.returnCode = returnCode;
        this.returnMessage = returnMessage;
        this.returnResult = returnResult;
        this.className = className;
        this.methodName = methodName;
        this.ip = ip;
        this.location = location;
        this.os = os;
        this.browser = browser;
    }

    public SecurityOperationLog(IDatabase dbOwner, String id, String resourceId, String client, String title, String type, String typeName, String userId, String userName, Long createTime, String requestUrl, String requestParam, String returnCode, String returnMessage, String returnResult, String className, String methodName, String ip, String location, String os, String browser) {
        super(dbOwner);
        this.id = id;
        this.resourceId = resourceId;
        this.client = client;
        this.title = title;
        this.type = type;
        this.typeName = typeName;
        this.userId = userId;
        this.userName = userName;
        this.createTime = createTime;
        this.requestUrl = requestUrl;
        this.requestParam = requestParam;
        this.returnCode = returnCode;
        this.returnMessage = returnMessage;
        this.returnResult = returnResult;
        this.className = className;
        this.methodName = methodName;
        this.ip = ip;
        this.location = location;
        this.os = os;
        this.browser = browser;
    }

    @Override
    public String getId() {
        return id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }

    public String getClient() {
        return client;
    }

    public void setClient(String client) {
        this.client = client;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public String getRequestUrl() {
        return requestUrl;
    }

    public void setRequestUrl(String requestUrl) {
        this.requestUrl = requestUrl;
    }

    public String getRequestParam() {
        return requestParam;
    }

    public void setRequestParam(String requestParam) {
        this.requestParam = requestParam;
    }

    public String getReturnCode() {
        return returnCode;
    }

    public void setReturnCode(String returnCode) {
        this.returnCode = returnCode;
    }

    public String getReturnMessage() {
        return returnMessage;
    }

    public void setReturnMessage(String returnMessage) {
        this.returnMessage = returnMessage;
    }

    public String getReturnResult() {
        return returnResult;
    }

    public void setReturnResult(String returnResult) {
        this.returnResult = returnResult;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getOs() {
        return os;
    }

    public void setOs(String os) {
        this.os = os;
    }

    public String getBrowser() {
        return browser;
    }

    public void setBrowser(String browser) {
        this.browser = browser;
    }


    public Builder bind() {
        return new Builder(this);
    }

    public static Builder builder() {
        return new Builder();
    }

        public static Builder builder(IDatabase dbOwner) {
            return new Builder(dbOwner);
        }

    public static class Builder {

        private final SecurityOperationLog targetEntity;

        public Builder() {
            targetEntity = new SecurityOperationLog();
        }

        public Builder(IDatabase dbOwner) {
            targetEntity = new SecurityOperationLog(dbOwner);
        }

        public Builder(SecurityOperationLog targetEntity) {
            this.targetEntity = targetEntity;
        }

        public SecurityOperationLog build() {
            return targetEntity;
        }

        public IDatabaseConnectionHolder connectionHolder() {
            return targetEntity.getConnectionHolder();
        }

        public Builder connectionHolder(IDatabaseConnectionHolder connectionHolder) {
            targetEntity.setConnectionHolder(connectionHolder);
            return this;
        }

        public IDatabase dbOwner() {
            return targetEntity.getDbOwner();
        }

        public Builder dbOwner(IDatabase dbOwner) {
            targetEntity.setDbOwner(dbOwner);
            return this;
        }

        public String dataSourceName() {
            return targetEntity.getDataSourceName();
        }

        public Builder dataSourceName(String dataSourceName) {
            targetEntity.setDataSourceName(dataSourceName);
            return this;
        }

        public IShardingable shardingable() {
            return targetEntity.getShardingable();
        }

        public Builder shardingable(IShardingable shardingable) {
            targetEntity.setShardingable(shardingable);
            return this;
        }


        public String id() {
            return targetEntity.getId();
        }

        public Builder id(String id) {
            targetEntity.setId(id);
            return this;
        }

        public String resourceId() {
            return targetEntity.getResourceId();
        }

        public Builder resourceId(String resourceId) {
            targetEntity.setResourceId(resourceId);
            return this;
        }

        public String client() {
            return targetEntity.getClient();
        }

        public Builder client(String client) {
            targetEntity.setClient(client);
            return this;
        }

        public String title() {
            return targetEntity.getTitle();
        }

        public Builder title(String title) {
            targetEntity.setTitle(title);
            return this;
        }

        public String type() {
            return targetEntity.getType();
        }

        public Builder type(String type) {
            targetEntity.setType(type);
            return this;
        }

        public String typeName() {
            return targetEntity.getTypeName();
        }

        public Builder typeName(String typeName) {
            targetEntity.setTypeName(typeName);
            return this;
        }

        public String userId() {
            return targetEntity.getUserId();
        }

        public Builder userId(String userId) {
            targetEntity.setUserId(userId);
            return this;
        }

        public String userName() {
            return targetEntity.getUserName();
        }

        public Builder userName(String userName) {
            targetEntity.setUserName(userName);
            return this;
        }

        public Long createTime() {
            return targetEntity.getCreateTime();
        }

        public Builder createTime(Long createTime) {
            targetEntity.setCreateTime(createTime);
            return this;
        }

        public String requestUrl() {
            return targetEntity.getRequestUrl();
        }

        public Builder requestUrl(String requestUrl) {
            targetEntity.setRequestUrl(requestUrl);
            return this;
        }

        public String requestParam() {
            return targetEntity.getRequestParam();
        }

        public Builder requestParam(String requestParam) {
            targetEntity.setRequestParam(requestParam);
            return this;
        }

        public String returnCode() {
            return targetEntity.getReturnCode();
        }

        public Builder returnCode(String returnCode) {
            targetEntity.setReturnCode(returnCode);
            return this;
        }

        public String returnMessage() {
            return targetEntity.getReturnMessage();
        }

        public Builder returnMessage(String returnMessage) {
            targetEntity.setReturnMessage(returnMessage);
            return this;
        }

        public String returnResult() {
            return targetEntity.getReturnResult();
        }

        public Builder returnResult(String returnResult) {
            targetEntity.setReturnResult(returnResult);
            return this;
        }

        public String className() {
            return targetEntity.getClassName();
        }

        public Builder className(String className) {
            targetEntity.setClassName(className);
            return this;
        }

        public String methodName() {
            return targetEntity.getMethodName();
        }

        public Builder methodName(String methodName) {
            targetEntity.setMethodName(methodName);
            return this;
        }

        public String ip() {
            return targetEntity.getIp();
        }

        public Builder ip(String ip) {
            targetEntity.setIp(ip);
            return this;
        }

        public String location() {
            return targetEntity.getLocation();
        }

        public Builder location(String location) {
            targetEntity.setLocation(location);
            return this;
        }

        public String os() {
            return targetEntity.getOs();
        }

        public Builder os(String os) {
            targetEntity.setOs(os);
            return this;
        }

        public String browser() {
            return targetEntity.getBrowser();
        }

        public Builder browser(String browser) {
            targetEntity.setBrowser(browser);
            return this;
        }
    }

    public interface FIELDS {
        String ID = "id";
        String RESOURCE_ID = "resource_id";
        String CLIENT = "client";
        String TITLE = "title";
        String TYPE = "type";
        String TYPE_NAME = "type_name";
        String USER_ID = "user_id";
        String USER_NAME = "user_name";
        String CREATE_TIME = "create_time";
        String REQUEST_URL = "request_url";
        String REQUEST_PARAM = "request_param";
        String RETURN_CODE = "return_code";
        String RETURN_MESSAGE = "return_message";
        String RETURN_RESULT = "return_result";
        String CLASS_NAME = "class_name";
        String METHOD_NAME = "method_name";
        String IP = "ip";
        String LOCATION = "location";
        String OS = "os";
        String BROWSER = "browser";
    }

    public static final String TABLE_NAME = "security_operation_log";

    public static FieldConditionBuilder conditionBuilder() {
        return new FieldConditionBuilder();
    }

    public static FieldConditionBuilder conditionBuilder(String prefix) {
        return new FieldConditionBuilder(prefix);
    }

    public static FieldConditionBuilder conditionBuilder(Query<?> query) {
        return conditionBuilder(query, null);
    }

    public static FieldConditionBuilder conditionBuilder(Query<?> query, String prefix) {
        return new FieldConditionBuilder(query.owner(), query.dataSourceName(), prefix);
    }

    public static FieldConditionBuilder conditionBuilder(SecurityOperationLog entity) {
        return conditionBuilder(entity, null);
    }

    public static FieldConditionBuilder conditionBuilder(SecurityOperationLog entity, String prefix) {
        return new FieldConditionBuilder(entity.doGetSafeOwner(), entity.getDataSourceName(), prefix);
    }

    public static FieldConditionBuilder conditionBuilder(IDatabase owner, String prefix) {
        return new FieldConditionBuilder(owner, prefix);
    }

    public static FieldConditionBuilder conditionBuilder(IDatabase owner, String dataSourceName, String prefix) {
        return new FieldConditionBuilder(owner, dataSourceName, prefix);
    }

    public static class FieldConditionBuilder extends AbstractFieldConditionBuilder {

        public FieldConditionBuilder() {
            super(null, null, null);
        }

        public FieldConditionBuilder(String prefix) {
            super(null, null, prefix);
        }

        public FieldConditionBuilder(Query<?> query) {
            super(query.owner(), null, null);
        }

        public FieldConditionBuilder(Query<?> query, String prefix) {
            super(query.owner(), query.dataSourceName(), prefix);
        }

        public FieldConditionBuilder(IDatabase owner) {
            super(owner, null, null);
        }

        public FieldConditionBuilder(IDatabase owner, String prefix) {
            super(owner, null, prefix);
        }

        public FieldConditionBuilder(IDatabase owner, String dataSourceName, String prefix) {
            super(owner, dataSourceName, prefix);
        }

        public FieldCondition id() {
            return createFieldCondition(FIELDS.ID);
        }

        public FieldCondition resourceId() {
            return createFieldCondition(FIELDS.RESOURCE_ID);
        }

        public FieldCondition client() {
            return createFieldCondition(FIELDS.CLIENT);
        }

        public FieldCondition title() {
            return createFieldCondition(FIELDS.TITLE);
        }

        public FieldCondition type() {
            return createFieldCondition(FIELDS.TYPE);
        }

        public FieldCondition typeName() {
            return createFieldCondition(FIELDS.TYPE_NAME);
        }

        public FieldCondition userId() {
            return createFieldCondition(FIELDS.USER_ID);
        }

        public FieldCondition userName() {
            return createFieldCondition(FIELDS.USER_NAME);
        }

        public FieldCondition createTime() {
            return createFieldCondition(FIELDS.CREATE_TIME);
        }

        public FieldCondition requestUrl() {
            return createFieldCondition(FIELDS.REQUEST_URL);
        }

        public FieldCondition requestParam() {
            return createFieldCondition(FIELDS.REQUEST_PARAM);
        }

        public FieldCondition returnCode() {
            return createFieldCondition(FIELDS.RETURN_CODE);
        }

        public FieldCondition returnMessage() {
            return createFieldCondition(FIELDS.RETURN_MESSAGE);
        }

        public FieldCondition returnResult() {
            return createFieldCondition(FIELDS.RETURN_RESULT);
        }

        public FieldCondition className() {
            return createFieldCondition(FIELDS.CLASS_NAME);
        }

        public FieldCondition methodName() {
            return createFieldCondition(FIELDS.METHOD_NAME);
        }

        public FieldCondition ip() {
            return createFieldCondition(FIELDS.IP);
        }

        public FieldCondition location() {
            return createFieldCondition(FIELDS.LOCATION);
        }

        public FieldCondition os() {
            return createFieldCondition(FIELDS.OS);
        }

        public FieldCondition browser() {
            return createFieldCondition(FIELDS.BROWSER);
        }
    }
}
